package src;

/**
 * LinkedSet
 */
public class LinkedSet<E> implements Set<E> {

    private LinkedList<E> list;

    public LinkedSet(){
        list = new LinkedList<>();
    }

    @Override
    public void add(E e) {
        if (! list.contains(e)) {
            list.addFirst(e);
        }
    }

    @Override
    public void remove(E e) {
        int index = list.find(e);
        if (index != -1) {
            list.remove(index);
        }
    }

    @Override
    public boolean contains(E e) {
        return list.contains(e);
    }

    @Override
    public boolean isEmpty() {
        return list.isEmpty();
    }

    @Override
    public int getSize() {
        return list.getSize();
    }

    
}